package parser.nodes;

import codegen.CodeGen;
import java.util.ArrayList;
import java.util.List;

// StatementSequence = Statement {';' Statement}
public class StatementSequenceNode extends Node{
    private List<StatementNode> statements = new ArrayList<>();

    public StatementSequenceNode(StatementNode stmt) {
        statements.add(stmt);
    }
    
    public void add(StatementNode stmt) {
        statements.add(stmt);
    }

    @Override
    public void print() {
        p("StatementSequence:");
        indent();
        for(StatementNode stmt : statements) {
            stmt.print();
            p(";");
        }
        unindent();
    }

    @Override
    public void abstractPrint() {
        p("STATEMENTSEQ");
        indent();
        for(StatementNode stmt : statements)
            stmt.abstractPrint();
        unindent();
    }

    @Override
    public void compile(CodeGen c) throws CompileError {
        for(StatementNode stmt : statements)
            stmt.compile(c);
    }
}
